import axios from 'axios'
import moment from 'moment'
import qs from 'qs'
// 生成树状数据结构
function tree(data,pid=0,res=[]){
      data.forEach(function(row){
            if(row.pid==pid){
                  row.children=[],
                  res.push(row)
                  tree(data,row.id,row.children)
            }
      })
      return res
}

// 设置axios请求的默认地址及端口号
axios.defaults.baseURL="http://101.132.158.158:8888"
// 设置express-session允许跨域
axios.defaults.withCredentials=true
import jquery from 'jquery'
export default {
      install(vue,params){
            vue.prototype.apiurl='http://101.132.158.158:8888',
            vue.prototype.$http=axios
            vue.prototype.jq=jquery
            vue.prototype.$qs=qs
            vue.prototype.$tree=tree
            vue.prototype.$moment=moment
      }
}